 import Mock from 'mockjs'
 // mock的配置
 Mock.setup({
     // 随机延时500-1000毫秒
     timeout: '500-1000'
 })

 // mock我的足迹
 Mock.mock(/\/member\/browseHistory/, 'get', (config) => {
     // 接收筛选条件
     const queryStr = JSON.parse(config.body)
     const page = queryStr.page
     const pageSize = queryStr.pageSize

     // 模拟数据
     const {
         list
     } = Mock.mock({
         'list|100': [{
             id: '@increment',
             name: '@ctitle(10,20)',
             desc: '@ctitle(4,10)',
             picture: "@image('50*50','#FF83FA','#FCFCFC','png','mono')",
             price: '@float(100,200,2,2)'
         }]
     })

     // 计算总页数和总记录
     const counts = list.length
     const pages = Math.ceil(counts / pageSize)

     // 获取分页数据
     const start = (page - 1) * pageSize
     const end = pageSize * page
     const items = page > pages ? [] : list.slice(start, end)

     return {
         msg: '操作成功',
         result: {
             counts,
             pageSize,
             page,
             pages,
             items
         }
     }
 })

 // mock 我的收藏
 Mock.mock(/\/member\/collect/, 'get', (config) => {
     // 接收筛选条件
     const queryStr = JSON.parse(config.body)
     const page = queryStr.page
     const pageSize = queryStr.pageSize
     const collectType = queryStr.collectType

     // 模拟数据
     let list = []
     if (collectType === 1) {
         list = Mock.mock({
             'list|75': [{
                 id: '@increment',
                 name: '@ctitle(10,20)',
                 desc: '@ctitle(4,10)',
                 picture: "@image('50*50','#FF83FA','#FCFCFC','png','mono')",
                 price: '@float(100,200,2,2)'
             }]
         }).list
     }

     // 计算总页数和总记录
     const counts = list.length
     const pages = Math.ceil(counts / pageSize)

     // 获取分页数据
     const start = (page - 1) * pageSize
     const end = pageSize * page
     const items = page > pages ? [] : list.slice(start, end)

     return {
         msg: '操作成功',
         result: {
             counts,
             pageSize,
             page,
             pages,
             items
         }
     }
 })